<%= breadcrumb @project, "Stages" %>

<% page_title "#{@project.name} Stages" %>

<section class="tabs">
  <ul id="stages" data-url="<%= reorder_project_stages_path(@project) %>" data-sortable="<%= admin_for_project? %>">
    <% @stages.each.with_index do |stage, index| %>
      <li class="stage-bar bar list-unstyled clearfix<%= ' sortable' if admin_for_project? %>" data-id="stage_id_<%= stage.id %>">
        <%= link_to stage.name, [@project, stage] %>
        <%= resource_lock_icon stage %>
        <%= stage.is_template ? stage_template_icon : '' %>
        <div class="btn-group pull-right">
          <% if admin_for_project? %>
            <%= link_to "Clone", clone_project_stage_path(@project, stage), class: "btn btn-default" %>
          <% end %>
          <%= deploy_link @project, stage %>
        </div>
      </li>
    <% end %>
  </ul>

  <% if admin_for_project? %>
    <%= link_to "New", new_project_stage_path(@project), class: "btn btn-default" %>
  <% end %>

  <button id="error_message" class="messages btn btn-danger" disabled>
    Failed to save
  </button>

  <button id="success_message" class="messages btn btn-success" disabled>
    Saved
  </button>
</section>
